/**
 * 全局对象封装
 */

class Actions {
  // 默认值为空 Action
  actions = {
    onGlobalStateChange: () => {},
    setGlobalState: () => {}
  };

  /**
   * 设置 actions
   */
  setActions(actions: { onGlobalStateChange: any; setGlobalState?: () => void; }) {
    // @ts-ignore
    this.actions = actions;
  }

  /**
   * 映射
   */
  onGlobalStateChange(...args: any[]) {
    return this.actions.onGlobalStateChange(...args);
  }

  /**
   * 映射
   */
  setGlobalState(...args: any[]) {
    return this.actions.setGlobalState(...args);
  }
}

const actions = new Actions();

export default actions;
